<template>
	<!-- 新闻动态 -->
	<publicity-list :publicityList="newsList" infoType='2' @getDetail="getDetail" />
</template>

<script>
	import publicityList from '@/components/publicity-list.vue'
	import {propagateNewsApi} from '@/api/news/propagate-news-api.js'
	export default {
		components: {
			publicityList
		},
		data() {
			return {
				newsList: [],
				title: '',
				newsRequest:{
					page:1,
					limit:10,
					contentType:0,
				},
			}
		},
		onLoad(options) {
			let title = options.title
			this.title = title
			if(title) {
				uni.setNavigationBarTitle({
					title
				})
			}
			const contentType = options.contentType;
			this.newsRequest.contentType = contentType;
			this.getNewsList();
			
		},
		methods: {
			getDetail(id) {
				uni.navigateTo({
				    url: '../../publicity-education/news-information/detail?id='+id
				});
			},
			async getNewsList(){
				uni.showLoading({
					title:'加载中',
				})
				this.newsList = [];
				const result = await propagateNewsApi.queryList(this.newsRequest);
				uni.hideLoading();
				this.newsList = result.data.list;
				for (var i = 0; i < this.newsList.length; i++) {
					let item = this.newsList[i];
					let pic = item.surfacePlot.split(',');
					item.surfacePlots = pic;
				}
			}
		}
	}
</script>